package com.example.seven;

import android.app.Activity;
import android.os.Bundle;
import android.view.Menu;
import android.view.MenuItem;
import android.view.View;
import android.widget.Button;
import android.widget.PopupMenu;

public class Main2Activity extends Activity {

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main2);
        Button btn=(Button) findViewById(R.id.btn_menu);
}
    public void popupMenu(View view){
        PopupMenu popupMenu = new PopupMenu(this,view);
        MenuInflater inflater = popupMenu.getMenuInflater();
        popupMenu.setOnMenuItemClickListener((item)->{
            switch (item.getItemId()){
                case R.id.password_xiugai:
                    return true;
                case R.id.class_guanlian:
                    return true;
                case R.id.kecheng_guanlian:
                    return true;
                case R.id.grade_pingshi:
                    return true;
                case R.id.grade_kaoshi:
                    return  true;
                default:
                    return false;
            }
        });
        inflater.inflate(R.menu.menu,popupMenu.getMenu());
        popupMenu.show();
    }

	@Override
	public boolean onCreateOptionsMenu(Menu menu) {
		// Inflate the menu; this adds items to the action bar if it is present.
		getMenuInflater().inflate(R.menu.main2, menu);
		return true;
	}

	@Override
	public boolean onOptionsItemSelected(MenuItem item) {
		// Handle action bar item clicks here. The action bar will
		// automatically handle clicks on the Home/Up button, so long
		// as you specify a parent activity in AndroidManifest.xml.
		int id = item.getItemId();
		if (id == R.id.action_settings) {
			return true;
		}
		return super.onOptionsItemSelected(item);
	}
}
